{extend name='base' /}
{block name='content'}
<!--页面主要内容-->
<main class="lyear-layout-content">

    <div class="container-fluid">

        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header">
                        <h4>视频添加</h4>
                    </div>
                    <div class="card-body">
                        <form action="#!" method="post" class="row" >
                            <div class="form-group col-md-12">
                                <label>视频名称</label>
                                <input type="text" class="form-control" id="othvideo_name" name="othvideo_name" value="" required  placeholder="请输入视频名称" />
                            </div>
                            <div class="form-group col-md-12" id="thumb-form">
                                <label>缩略图</label><br>
                                <input type="text" class="form-control" id="thumb" required  style="display: none" name="othvideo_thumb" value="" />
                                <button type="button" class="layui-btn" id="upimg">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                            </div>
                            <div class="form-group col-md-12">
                                <label>视频资源</label>
                                <div class="input-group" id="video-group">
                                    <input type="text" class="form-control"  multiple="multiple" required name="othvideo_url" id="video_url" value="" placeholder="填写视频资源地址或者上传视频">
                                    <div class="input-group-btn">
                                        <button type="button" class="layui-btn" id="uploadvideo">
                                            <i class="layui-icon">&#xe67c;</i>上传视频
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group col-md-12">
                                <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">上传</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

        </div>

    </div>

</main>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#uploadvideo' //绑定元素
            ,accept: 'video'
            ,url: '{:url("admin/upload/uploadvideo")}'//上传接口
            ,done: function(res){
                //上传完毕回调
                $("#video_url").val(res.data.src);
            }
            ,error: function(){
                //请求异常回调
            }
        });
        var uploadthumb = upload.render({
            elem: '#upimg' //绑定元素
            ,url: '{:url("admin/upload/uploadduansp")}' //上传接口
            ,accept: 'images' //允许上传的文件类型
            ,size: 7000 //最大允许上传的文件大小
            ,done: function(res){
                if(res.code==0){
                    layer.msg('上传成功', {icon: 1});
                    $("#thumb").val(res.data.src);
                    $("#thumb").css("display","block");
                }else {
                    layer.msg(res.msg, {icon: 2});
                }

            }
            ,error: function(){
                //请求异常回调
            }
        });

    });
</script>
<script>
    {/block}